{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
    <link rel="stylesheet" type="text/css" href="/css/mediation/entryrepay/index.css" />
{/block}

{block name="page_section"}


    <div class="sessionPage bg-fff">
        <input type="hidden" id="delete_id" value="">
        <div class="page-header">
          <div class="left">
            <span class="line"></span>
            <strong class="tit">还款审核</strong>
          </div>
        </div>
        <form method="get" action="" class="clearfix small-style" role="validform" enctype="multipart/form-data">
          <div class="form_row">
            <input type="hidden" name="limit" value="{if $query.limit}{$query.limit}{/if}">
            <div class="form-group  col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">调解部门:</label>
                <div class="col-sm-7">
                    <select class="form-control" name="mediationOrganId">
                        <option class="u144_input_option"  {if $query.mediationOrganId=='0'}selected="selected"{/if} value="0">全部</option>
                        {foreach from=$mediationOrgan item=item key=key}
                            <option class="u144_input_option" {if $query.mediationOrganId==$key}selected="selected"{/if} value="{$key}">{$item.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">审核状态:</label>
                <div class="col-sm-7">
                    <select class="form-control selectpicker" name="status" id="newzttype" title="请选择">
                        {foreach from=$planStatusArr key=key item=item}
                            {if in_array($key,['wait_plan','reject_plan','finish_plan'])}
                            <option class="u144_input_option" {if $query.status=={$key}}selected="selected"{/if} value="{$key}">{$item}</option>
                            {/if}
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">当事人:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.litigantName)}{$query.litigantName}{/if}" name="litigantName" id="litigantName" placeholder="请输入~">
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">案件号:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.caseId)}{$query.caseId}{/if}" name="caseId" id="caseId" placeholder="请输入~">
                </div>
            </div>
          </div>
          <div class="form_row">
            <div class="form-group col-lg-3 ui-select">
                <div class="col-lg-4">
                    <button class="btn btn-primary col-lg-8 shousuoBtn"><span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
                </div>
                <div class="col-lg-4">
                    <a type="button" href="/returnedmoneyplan/checklist" class="btn btn-default col-lg-8" ><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
                </div>
            </div>
            <div class="ui-select"></div>
            <div class="ui-select"></div>
            <div class="ui-select"></div>
          </div>

        </form >
        <div style="width: 95%;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        overflow-x: scroll;">
            <table class="table table-striped table-bordered table-hover text-nowrap">
            <thead>
            <tr>
                <th scope="col">序号</th>
                <th scope="col">案件号</th>
                <th scope="col">调解组</th>
                <th scope="col">当事人</th>
                <th scope="col">添加人</th>
                <th scope="col">审核状态</th>
                <th scope="col">预计还款金额</th>
                <th scope="col">实际还款金额</th>
                <th scope="col">预计还款日期</th>
                <th scope="col">实际还款日期</th>
                <th scope="col">添加时间</th>
                <th scope="col">更新时间</th>
                <th scope="col">还款备注</th>
                <th scope="col" class="fix-ele">操作</th>
            </tr>
            </thead>

            <tbody>
            {if $list}
                {foreach from=$list item=info key=key name=a}
                    <tr>
                        <td>{$info['id']}</td>
                        <td>{$info['caseId']}</td>
                        <td>{$mediationOrgan[$info['mediationOrganId']]['name']}</td>
                        <td>{$info['litigantName']}</td>
                        <td>{$info['mediatorName']}</td>
                        <td>{$planStatusArr[$info['status']]}</td>
                        <td>{$info['repayAmount']}</td>
                        <td>{$info['realRepayAmount']}</td>
                        <td>{if !empty($info['repaymentDate'])}{$info['repaymentDate']|date_format:"%Y/%m/%d"}{/if}</td>
                        <td>{if !empty($info['realRepaymentDate'])}{$info['realRepaymentDate']|date_format:"%Y/%m/%d"}{/if}</td>
                        <td>{if !empty($info['addTime'])}{$info['addTime']|date_format:"%Y/%m/%d"}{/if}</td>
                        <td>{if !empty($info['updateTime'])}{$info['updateTime']|date_format:"%Y/%m/%d"}{/if}</td>
                        <td>{$info['notes']} {$info['notesCheck']}</td>

                        <td class="fix-ele">
                            <a href="javascript:;"  class="editTransfer"  data-toggle="modal" data-target="#modal_edit" data-id='{$info['id']}' data-litigantName='{$info['litigantName']}' data-realRepayAmount='{$info['realRepayAmount']}' data-notesCheck='{$info['notesCheck']}' data-realRepaymentDate='{$info['realRepaymentDate']|date_format:"%Y-%m-%d"}'>审核</a>

                        <a href="../{$info.filepath}" target="_blank" class='withdraw_one' >查阅凭证</a>

                        </td>
                    </tr>
                {/foreach}
            {/if}
            </tbody>
        </table>
        </div>
        <div class="clearfix pad-no text-nowrap" style="margin-top: 20px;">
            {include file="base/pagenav.html"  action="/returnedmoneyplan/checklist" pagenum=$curPageNum inline}
            <select class="form-control" id="paglimit" style="float:right;margin:0 10px;width: auto;margin-top: -5px;">
                <option value="limit=10" {if $query.limit==10}selected="selected"{/if}>10条/页</option>
                <option value="limit=20" {if $query.limit==20}selected="selected"{/if}>20条/页</option>
                <option value="limit=50" {if $query.limit==50}selected="selected"{/if}>50条/页</option>
                <option value="limit=100" {if $query.limit==100}selected="selected"{/if}>100条/页</option>
            </select>
            <span style="float:right;">共 {$totalnum} 条</span>
        </div>
    </div>


    <div class="modal fade" id="modal_edit" tabindex="-1" role="dialog" aria-labelledby="refusal_modal" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <form id="modal_edit_form">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="exampleModalLabel">审核-当事人 <span id="litigantName1"></span></h4>
                    </div>
                    <div class="modal-body" style="padding-left: 100px;height: 270px">
                        <input type="hidden" name="detail_id" id="detail_id" value="0">
                        <div class="form-group col-lg-10 ui-select">
                            <label for="exampleInputName2"  class="col-sm-4 control-label">实际还款日期:</label>
                            <div class="col-sm-8">
                                <input type="date" class="form-control"  id="realRepaymentDate"  value="" name="realRepaymentDate" placeholder="实际还款日期">
                            </div>
                        </div>
                        <div class="form-group col-lg-10 ui-select">
                            <label for="inputEmail3" class="col-sm-4 control-label">实际还款金额:</label>
                            <div class="col-sm-8">
                                <input type="number" name="realRepayAmount"  class="form-control" id="realRepayAmount" step="0.01" value="" placeholder="实际还款金额,保留2位小数" data-valid="notempty" >
                            </div>

                        </div>
                        <div class="form-group col-lg-10 ui-select"  >
                            <label for="inputEmail3" class="col-sm-4 control-label">审核状态:</label>
                            <div class="col-sm-8">
                                <select class="form-control selectpicker" name="check_status" id="check_status" title="请选择">
                                    <option class="u144_input_option "  value="finish_plan">审核通过</option>
                                    <option class="u144_input_option "  value="reject_plan">审核驳回</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group col-lg-10 ui-select" style="margin-top:15px">
                            <label for="inputEmail3" class="col-sm-4 control-label">审核备注:</label>
                            <div class="col-sm-8">
                                <textarea name="notesCheck" class="form-control" rows="5"  id="notesCheck"></textarea>
                            </div>
                        </div>

                    </div>
                    <div class="modal-footer" style="text-align: center;">
                        <button type="button" class="btn btn-default" id="fpclosebtn" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary modal_edit_sure">确定</button>
                    </div>
                </form>
            </div>
        </div>
    </div>



{/block}
{block name="page_scripts"}
<script type="text/javascript">

    var lockfas= false;


    $(".editTransfer").on("click",function(){

        $("#detail_id").val($(this).attr("data-id"));
        $("#realRepaymentDate").val($(this).attr("data-realRepaymentDate"));
        $("#realRepayAmount").val($(this).attr("data-realRepayAmount"));

        $("#notesCheck").text($(this).attr("data-notesCheck"));
        $("#litigantName1").text($(this).attr("data-litigantName"));

        // $("#modal_upload").show();
    });


    $(".modal_edit_sure").on("click",function(){
        if(lockfas)return;
        lockfas = true;

        if($("#detail_id").val()==0){
            toastr.error('参数错误');
            return false;
        }

        $.ajax({
            type: "post",
            url:"/returnedmoneyplan/checkStatus",
            data:$("#modal_edit_form").serialize(),
            dataType:'json',
            success:function(res){
                if(res.code==200){
                    lockfas = false;
                    toastr.success(res.message);
                    setTimeout(function(){
                        window.location.reload();
                    },2000)
                }else{
                    lockfas = false;
                    toastr.error(res.message);
                }
            }
        })
        lockfas = false;

    })

    function GetQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    $('body').on('change','#paglimit', function(){
        console.log()
        var mediationOrganId = GetQueryString('mediationOrganId');
        var paglimit = GetQueryString('limit');
        var val =  $(this).val();
        if(!mediationOrganId){
            if(!paglimit){
                window.location = window.location.href+'?'+val;
            } else{
                window.location = window.location.href.replace('limit='+paglimit,val);
            }
        }else{
            if(!paglimit){
                window.location = window.location.href+'&'+val;
            } else{
                window.location = window.location.href.replace('limit='+paglimit,val);
            }
        }
    })



    </script>
{/block}
